def get_test1():
    from re_common.baselibrary.utils.basepika import BasePika

    basepika = BasePika()
    basepika.set_default()
    basepika.connect()
    basepika.create_channel()
    basepika.queue_declare()
    basepika.set_get_msg_callback()
    basepika.start_get_msg()


# get_test1()

def get_test2():
    from re_common.baselibrary.utils.basepika import BasePika

    basepika = BasePika()
    basepika.set_default()
    basepika.connect()
    basepika.create_channel()
    basepika.queue_declare(queue="task_queue", durable=True)
    basepika.queue_declare(queue="task_queue2", durable=True)
    basepika.basic_qos(1)
    basepika.set_get_msg_callback(routing_key="task_queue", auto_ack=False)
    basepika.set_get_msg_callback(routing_key="task_queue2", auto_ack=False)
    basepika.start_get_msg()


get_test2()

def get_test3():
    from re_common.baselibrary.utils.basepika import BasePika

    basepika = BasePika()
    basepika.set_default()
    basepika.connect()
    basepika.create_channel()
    basepika.exchange_declare()
    queuename = basepika.random_queue_declare().method.queue
    # 如果不绑定队列 消息将被忽略
    basepika.queue_bind(queue=queuename)
    basepika.set_get_msg_callback(routing_key=queuename, auto_ack=True)
    basepika.start_get_msg()


# get_test3()


def get_test4():
    from re_common.baselibrary.utils.basepika import BasePika

    basepika = BasePika()
    basepika.set_default()
    basepika.connect()
    basepika.create_channel()
    basepika.exchange_declare(exchangename="direct_logs", type="direct")
    queuename = basepika.random_queue_declare().method.queue
    # 通过key确认哪些消息过来
    basepika.queue_bind(exchange="direct_logs", queue=queuename, routing_key="2")
    basepika.queue_bind(exchange="direct_logs", queue=queuename, routing_key="1")
    basepika.set_get_msg_callback(routing_key=queuename, auto_ack=True)
    basepika.start_get_msg()


# get_test4()
def get_test5():
    from re_common.baselibrary.utils.basepika import BasePika

    basepika = BasePika()
    basepika.set_default()
    basepika.connect()
    basepika.create_channel()
    basepika.exchange_declare(exchangename="topic_logs", type="topic")
    queuename = basepika.random_queue_declare().method.queue
    # 通过key确认哪些消息过来 > * (星)  可代替一个单词
    # > # (井) 可代替0个或多个单词
    basepika.queue_bind(exchange="topic_logs", queue=queuename, routing_key="a.#")
    basepika.set_get_msg_callback(routing_key=queuename, auto_ack=True)
    basepika.start_get_msg()

#
# get_test5()
